module cntm #(
    parameter CNTM = 40  // Default value for CNTM
)(
	input clk,	//1Hz
	input enable,
	output W);
	
	reg[width(CNTM)-1:0] cnt;
	
	always @(posedge clk )
	begin
		if(enable == 1'b1 && cnt < CNTM-1)
			cnt <= cnt+1'b1;
		else
			cnt <= 0;
	end
	assign W=(cnt == CNTM-1);
	
	function integer width;   	//return width     
		input integer size;
		begin
		  for(width=0;size>0;width=width+1)
			 size=size>>1;
		end
	endfunction	
	
endmodule
	
	
	